package demo._go;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	private static final String PATTERN = "yyyy��MM��dd�� HH:mm:ss";

	public static String dateToString(Date date) {
		return dateToString(date, null);
	}

	public static String dateToString(Date date, String pattern) {
		SimpleDateFormat sdf = new SimpleDateFormat();
		sdf.applyPattern((pattern == null || pattern.equals("")) ? PATTERN : pattern);
		return sdf.format(date);
	}

	public static Date stringToDate(String str, String pattern) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat();
		sdf.applyPattern((pattern == null || pattern.equals("")) ? PATTERN : pattern);
		return sdf.parse(str);
	}
}
